package day07;

import java.util.Scanner;

public class CalTotalAvg2 {
    public static void main(String[] args) {
        double[] scores = enterData();
        double total = calTotal(scores);
        double avg = calAvg(scores);
        System.out.println("选手最后的得分为:"+avg );


    }

    public static double[] enterData() {
        double[] num = new double[6];
        Scanner scan = new Scanner(System.in);
        for (int i = 0; i <num.length; i++) {
            System.out.println("请第" + (i+1) + "位评委打分:");
            num[i] = scan.nextDouble();
        }
        return num;
    }
    public static double calTotal(double[] num){
        double total = 0.0;
        double max = num[0];
        double min = num[0];
        for (int i =0;i<num.length;i++){
            if (num[i]>max){
                max = num[i];
            }
            if (num[i]<min){
                min = num[i];
            }
            total +=num[i];
        }

        return  total-max-min;
    }
    public static double calAvg(double[] scores){
        double total = calTotal(scores);
        double avg = total/(scores.length-2);
        return avg;
    }
}


